package Cluster;

import java.util.HashMap;

import XmlLoader.Position;

public class HashClusterRange {

	protected HashMap<Integer, Integer> hashRowMin = null, hashRowMax = null;
	protected HashMap<Integer, Integer> hashColMin = null, hashColMax = null;
	
	public HashClusterRange() {
		this.hashRowMin = new HashMap<Integer, Integer>();
		this.hashRowMax = new HashMap<Integer, Integer>();
		this.hashColMin = new HashMap<Integer, Integer>();
		this.hashColMax = new HashMap<Integer, Integer>();
	}
	
	public void __001_checkMin(int hash, int value, HashMap<Integer, Integer> hashMap) {
		Integer getOrgValue = hashMap.get(hash);
		if(getOrgValue == null) {  //add new hash
			hashMap.put(hash, value);
		}
		else {
			if(value < getOrgValue) {  //the minimal value is updated
				hashMap.put(hash, value);
			}
		}
	}
	
	public void __002_checkMax(int hash, int value, HashMap<Integer, Integer> hashMap) {
		Integer getOrgValue = hashMap.get(hash);
		if(getOrgValue == null) {  //add new hash
			hashMap.put(hash, value);
		}
		else {
			if(value > getOrgValue) {  //the maximal value is updated
				hashMap.put(hash, value);
			}
		}
	}
	
	public void ACT001_chackPoint(Position point) {
		this.__001_checkMin(point.y, point.x, this.hashRowMin);
		this.__002_checkMax(point.y, point.x, this.hashRowMax);
		this.__001_checkMin(point.x, point.y, this.hashColMin);
		this.__002_checkMax(point.x, point.y, this.hashColMax);
	}
	
	public HashMap<Integer, Integer> GET001_HashRowMin() {
		return hashRowMin;
	}

	public HashMap<Integer, Integer> GET002_HashRowMax() {
		return hashRowMax;
	}

	public HashMap<Integer, Integer> GET003_HashColMin() {
		return hashColMin;
	}

	public HashMap<Integer, Integer> GET004_HashColMax() {
		return hashColMax;
	}
}
